import { createRouter, createWebHistory } from "vue-router";
import index from "@/views/index/index.vue";
import { homeRoutes } from "@/router/home";

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "/",
      name: "home",
      component: index,
      //默认打开第一个children
      redirect: `/${homeRoutes[homeRoutes.length - 1].path}`,
      children: homeRoutes,
    },
  ],
  scrollBehavior(to, from, savedPosition) {
    // console.log(to, from, savedPosition);
    return { top: 0 };
  },
});

export default router;
